/**
 * Copyright 2008 by Robert Konigsberg
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the same terms as Perl.
 *
 * @see http://www.perl.com/perl/misc/Artistic.html
 */
package visitor.maze;

import org.testng.annotations.Test;

@Test
public class MazeBuilderTest {

  @Test 
  public void startsEmpty() {
    assert new MazeBuilder().getMaze().getRoomIds().isEmpty();
  }

  @Test 
  public void oneWayConnect() {
    Maze maze = new MazeBuilder()
        .oneWayConnect(1, 2, Direction.NORTH)
        .getMaze();
    assert maze.getRoomIds().size() == 2;
    assert maze.getRoom(1).getExits().size() == 1;
    assert maze.getRoom(1).getExit(Direction.NORTH) == maze.getRoom(2);
    assert maze.getRoom(2).getExits().isEmpty();
  }

  @Test 
  public void twoWayConnect() {
    Maze maze = new MazeBuilder()
        .twoWayConnect(1, 2, Direction.NORTH)
        .getMaze();
    assert maze.getRoomIds().size() == 2;
    assert maze.getRoom(1).getExits().size() == 1;
    assert maze.getRoom(1).getExit(Direction.NORTH) == maze.getRoom(2);

    assert maze.getRoom(2).getExits().size() == 1;
    assert maze.getRoom(2).getExit(Direction.SOUTH) == maze.getRoom(1);
  }
}
